const app = new getApp();
var time = require("../../../../utils/util.js");

Page({

  /**
   * 页面的初始数据
   */
  data: {
    prompt: '',
    default_img: {},
    cancle_pay: 0,
    buyer_ip: '',
    combo_id: 0,
    combo_buy_num: 1,
    order_top_image: [1, 2, 3, 4, 5],
    order_tag: '',
    goods_sku_list: '',
    cart_list: '',
    address_id: 0,
    promotion_full_mail: {},
    is_virtual: -1, // 是否虚拟商品
    goods_sku_list: '',
    pay_money: 0.00, //应付金额
    mask_status: 0, //遮罩层
    pay_type_option: 0, //支付方式弹框
    delivery_option: 0, //配送方式弹框
    coupon_option: 0, //优惠券弹框
    coupon_id: 0, //优惠券
    coupon_money: 0.00, //优惠券金额
    integral: 0, //积分
    user_telephone: '', //手机号
    buyer_invoice: '', //留言
    balance: 0.00, //使用余额
    pay_type_id: 0, //支付方式ID
    pay_type_name: '', // 支付方式名称
    express_type_id: 0, // 配送方式ID
    delivery_type_name: '', // 配送方式名称
    order_invoice_money: 0.00, //发票税额
    invoice_option: 0, //发票弹框
    is_need_invoice: 0, //是否需要发票
    invoice_title: '', //发票抬头
    taxpayer_identification_number: '', //纳税人识别号
    invoice_content: '', //发票内容
    pick_up_id: 0, //自提点
    pick_up_name: '', //自提点
    express_company_id: 0, //物流公司id
    express_company_name: '', //物流公司
    shipping_time_option: 0, //配送时间弹框
    distribution_time_out: '',
    shipping_time_info: '',
    shipping_time: 0,
    use_point: 0, //抵现使用积分
    use_point_money: 0.00, //积分抵现金额
    max_use_point: 0, //最大使用积分
    is_full_payment: 0, //预售是否全款
    commitOrderFlag: 0,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    let that = this;
    let tag = app.checkEmpty(options.tag, 0);
    let promotion_info = {};

    // 订单类型
    let order_type = app.checkEmpty(options.order_type, 0);

    if (order_type == 0) {
      app.showBox(that, '无法获取订单信息');
      setTimeout(function() {
        wx.navigateBack({
          delta: 1
        })
      }, 1000);
    }

    // 优惠类型
    let promotion_type = app.checkEmpty(options.promotion_type, 0);

    // 参与拼团ID
    let group_id = 0;
    if (options.group_id) {
      group_id = options.group_id;
      promotion_info = JSON.stringify({
        tuangou_group_id: group_id
      });
    }

    // 组合套餐ID
    let combo_id = 0;
    if (options.combo_id) {
      combo_id = options.combo_id;
      let buy_num = app.checkEmpty(options.num, 1);
      promotion_info = {
        combo_package_info: {
          combo_package_id: combo_id,
          buy_num: buy_num
        }
      };
      promotion_info = JSON.stringify(promotion_info);
    }

    // 规格组
    let goods_sku_list = options.sku == undefined || options.sku == null ? '' : options.sku;
    if (goods_sku_list == '') {
      app.showBox(that, '无法获取商品信息');
      setTimeout(function() {
        wx.navigateBack({
          delta: 1
        })
      }, 1000);
    }

    that.setData({
      order_tag: tag,
      group_id: group_id,
      order_type: order_type,
      promotion_type: promotion_type,
      goods_sku_list: goods_sku_list,
      promotion_info: promotion_info
    })
    app.copyRightLoad(that);
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    let that = this;
    let cancle_pay = that.data.cancle_pay;
    if (cancle_pay == 1) {
      app.setTabParam('cancle_pay');
      let tab_param = app.globalData.tab_param;

      wx.switchTab({
        url: '/pages/member/member/member',
      })
      return;
    }

    let param = {
      order_type: that.data.order_type,
      goods_sku_list: that.data.goods_sku_list,
      promotion_type: that.data.promotion_type,
      promotion_info: that.data.promotion_info
    };

    app.defaultImg(that, true, JSON.stringify(param));
    app.getUserIp(that);
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 图片加载失败
   */
  errorImg: function(e) {
    let that = this;
    let index = e.currentTarget.dataset.index;
    let order_info = that.data.order_info;
    let default_img = that.data.default_img;
    let param = {};
    let img = order_info.itemlist[index].picture_info.pic_cover_small;

    if (default_img.is_use == 1) {
      let default_img = default_img.value.default_goods_img;
      if (img.indexOf(default_img) == -1) {
        let param_key = "order_info.itemlist[" + index + "].picture_info.pic_cover_small";

        param[param_key] = default_img;
        that.setData(param);
      }
    }
  },

  /**
   * 赠品图片加载失败
   */
  errorGiftImg: function(e) {
    let that = this;
    let index = e.currentTarget.dataset.index;
    let order_info = that.data.order_info;
    let default_img = that.data.default_img;
    let param = {};
    let img = order_info.goods_mansong_gifts[index].gift_goods.picture_info.pic_cover_small;

    if (default_img.is_use == 1) {
      let default_img = default_img.value.default_goods_img;
      if (img.indexOf(default_img) == -1) {
        let param_key = "order_info.goods_mansong_gifts[" + index + "].gift_goods.picture_info.pic_cover_small";

        param[param_key] = default_img;
        that.setData(param);
      }
    }
  },

  /**
   * 加载订单信息
   */
  loadInfo: function(param) {
    let that = this;
    app.sendRequest({
      url: 'System.Order.orderDataCollation',
      data: {
        data: param
      },
      success: function(res) {
        let code = res.code;
        let data = res.data;

        console.log(res);
        if (code == 0) {
          let order_type = app.checkEmpty(data.order_type, 0);
          let promotion_type = app.checkEmpty(data.promotion_type, 0);
          // 是否虚拟商品
          let is_virtual = app.checkEmpty(data.is_virtual, 0);

          // 收货地址
          let address = is_virtual == 1 ? {} : app.checkEmpty(data.address, {});
          let address_id = is_virtual == 1 ? 0 : app.checkEmpty(address.id, 0);
          if (address.address_info != undefined && is_virtual == 0) {
            address.address_info = address.address_info.replace(/&nbsp;/g, '　');
          }

          // 支付方式
          let pay_type = !app.checkArray(data.pay_type) ? [] : data.pay_type;
          let pay_type_id = pay_type[0] == undefined ? 0 : pay_type[0].type_id;
          let pay_type_name = pay_type[0] == undefined ? '' : pay_type[0].type_name;

          // 配送服务-------------------
          // 配送方式
          let express_type = is_virtual == 1 ? [] : app.checkEmpty(data.express_type, []);
          let express_type_id = express_type[0] == undefined ? 0 : express_type[0].type_id;
          let express_type_name = express_type[0] == undefined ? '' : express_type[0].type_name;

          // 物流公司
          let express_company_list = is_virtual == 1 ? [] : app.checkEmpty(data.express_company_list, []);
          let express_company_id = express_company_list[0] == undefined ? 0 : express_company_list[0].co_id;
          let express_company_name = express_company_list[0] == undefined ? '' : express_company_list[0].company_name;
          if (express_company_id != 0) {
            for (let index in express_company_list) {
              if (express_company_list[index].is_default == 1) {
                express_company_id = express_company_list[index].co_id;
                express_company_name = express_company_list[index].company_name;
                break;
              }
            }
          }

          // 自提点
          let pickup_point_list = is_virtual == 1 ? [] : app.checkEmpty(data.pickup_point_list, []);
          let pick_up_id = pickup_point_list[0] == undefined ? 0 : pickup_point_list[0].id;
          let pick_up_name = pickup_point_list[0] == undefined ? '' : pickup_point_list[0].name;


          // 送货时间
          let time_slot = is_virtual == 1 ? [] : app.checkEmpty(data.time_slot, []);
          let distribution_time_out = time_slot[0] == undefined ? '' : time_slot[0];
          let current_time = that.data.current_time;
          if (is_virtual == 0) {
            that.lodingShippingTime(that, current_time);
          }

          // 本地配送时间
          let distribution_time = is_virtual == 1 || data.distribution_time == null || data.distribution_time == undefined ? '' : data.distribution_time.replace(/&nbsp;g/, ' ');

          // 优惠券
          let coupon_list = !app.checkArray(data.coupon_list) ? [] : data.coupon_list;
          let coupon_id = coupon_list[0] == undefined ? 0 : coupon_list[0].coupon_id;
          let coupon_money = coupon_list[0] == undefined ? 0 : coupon_list[0].money;
          for (let index in coupon_list) {
            coupon_list[index].end_time = time.formatTime(coupon_list[index].end_time, 'Y-M-D');
            coupon_list[index].show_money = Math.round(coupon_list[index].money);
          }

          // 发票信息
          let invoice_info = is_virtual == 1 || data.invoice_info == null || data.invoice_info == undefined ? {} : data.invoice_info;
          let invoice_content = is_virtual == 1 || invoice_info.order_invoice_content_list == undefined || invoice_info.order_invoice_content_list[0] == undefined ? '' : invoice_info.order_invoice_content_list[0];
          if (is_virtual == 0) {
            invoice_info.order_invoice_content_list = !app.checkArray(invoice_info.order_invoice_content_list) ? [] : invoice_info.order_invoice_content_list;
            invoice_info.order_invoice_tax == null || invoice_info.order_invoice_tax == undefined ? 0 : invoice_info.order_invoice_tax;
          }

          // 积分抵现
          let max_use_point = data.max_use_point == null || data.max_use_point == undefined ? 0 : parseInt(data.max_use_point);

          // 兑换所需积分
          let total_buy_point = data.total_buy_point == null || data.total_buy_point == undefined ? 0 : parseInt(data.total_buy_point);

          that.setData({
            order_type: order_type,
            promotion_type,
            promotion_type,
            is_virtual: is_virtual,
            address: address,
            address_id: address_id,
            pay_type: pay_type,
            pay_type_id: pay_type_id,
            pay_type_name: pay_type_name,
            express_type: express_type,
            express_type_id: express_type_id,
            express_type_name: express_type_name,
            express_company_list: express_company_list,
            pickup_point_list: pickup_point_list,
            express_company_id: express_company_id,
            express_company_name: express_company_name,
            pick_up_id: pick_up_id,
            pick_up_name: pick_up_name,
            time_slot: time_slot,
            distribution_time_out: distribution_time_out,
            distribution_time: distribution_time,
            coupon_list: coupon_list,
            coupon_id: coupon_id,
            coupon_money: coupon_money,
            invoice_info: invoice_info,
            invoice_content: invoice_content,
            max_use_point: max_use_point,
            total_buy_point: total_buy_point
          })

          // 商品信息
          let goods_sku_array = !app.checkArray(data.goods_sku_array) ? [] : data.goods_sku_array;
          for (let index in goods_sku_array) {
            if (goods_sku_array[index].goods_picture_info != undefined && goods_sku_array[index].goods_picture_info.pic_cover_small != undefined) {
              let img = goods_sku_array[index].goods_picture_info.pic_cover_small;
              goods_sku_array[index].goods_picture_info.pic_cover_small = app.IMG(img);

            }
            // 预售尾款
            if (order_type == 6) {
              let goods = goods_sku_array[index];
              goods_sku_array[index].final_payment = parseFloat(goods.sku_price) - parseFloat(goods.presell_price);
              goods_sku_array[index].final_payment = parseFloat(goods_sku_array[index].final_payment).toFixed(2);
            }
          }

          // 赠品信息
          let gift_array = app.checkEmpty(data.gift_array, []);
          for (let index in gift_array) {
            if (app.checkEmpty(gift_array[index].goods_picture_info, '') != '' && app.checkEmpty(gift_array[index].goods_picture_info.pic_cover_small, '') != '') {
              gift_array[index].goods_picture_info.pic_cover_small = app.IMG(gift_array[index].goods_picture_info.pic_cover_small);
            }
          }
          that.setData({
            goods_sku_array: goods_sku_array,
            gift_array: gift_array
          })
          that.orderCalculate();
        }
      }
    })
  },

  /**
   * 加载配送时间
   */
  lodingShippingTime: function(that, current_time) {
    let shipping_time_list = {};

    for (let i = 3; i < 10; i++) {

      let date = new Date(current_time * 1000);
      date.setDate(date.getDate() + i);
      let year = date.getFullYear();
      let month = date.getMonth() + 1;
      let day = date.getDate();
      let week = "日一二三四五六".charAt(date.getDay());
      let time = Math.round(date.getTime() / 1000);

      shipping_time_list[i - 1] = {};
      shipping_time_list[i - 1].year = year;
      shipping_time_list[i - 1].month = month;
      shipping_time_list[i - 1].day = day;
      shipping_time_list[i - 1].week = week;
      shipping_time_list[i - 1].time = time;
    }
    //console.log(shipping_time);
    that.setData({
      shipping_time_list: shipping_time_list
    })
  },

  /**
   * 获取参数
   */
  getValue: function() {
    let that = this;

    // 初始化参数
    let data = {
      order_type: that.data.order_type,
      is_virtual: that.data.is_virtual,
      buyer_ip: that.data.buyer_ip,
      user_money: 0, // 用户余额
      platform_money: 0, // 平台余额
      shipping_info: {}, // 配送信息
      buyer_invoice: '', // 发票信息
      buyer_message: '', // 买家留言 
      promotion_type: that.data.promotion_type,
      coin: 0, // 购物币
      promotion_info: that.data.promotion_info,
      goods_sku_list: that.data.goods_sku_list,
      coupon_id: that.data.coupon_id,
    };

    if (data.is_virtual == 0) {
      // 实物商品
      data.shipping_info.shipping_type = that.data.express_type_id;

      if (data.shipping_info.shipping_type == 1) {
        // 商家配送
        data.shipping_info.shipping_company_id = that.data.shipping_company_id;
        data.shipping_info.shipping_time = that.data.shipping_time;
        data.shipping_info.distribution_time_out = that.data.distribution_time_out;
      } else if (data.shipping_info.shipping_type == 2) {
        // 自提
        data.shipping_info.pick_up_id = that.data.pick_up_id;
      }
    } else {
      // 虚拟商品
      data.user_telephone = that.data.user_telephone;
    }
    // 发票
    let is_need_invoice = that.data.is_need_invoice;
    if (is_need_invoice == 1) {
      data.buyer_invoice = that.data.invoice_title + '$' + that.data.invoice_content + '$' + that.data.taxpayer_identification_number;
    }
    data.pay_type = that.data.pay_type_id; // 支付方式
    data.buyer_message = that.data.buyer_message; // 留言
    data.buyer_message = that.data.buyer_message;
    data.point = that.data.use_point;
    data.address_id = that.data.address_id;
    // 预售订单
    if (data.order_type == 6) {
      data.presell_info = {
        is_full_payment: that.data.is_full_payment
      }
    }
    return data;
  },

  /**
   * 订单计算
   */
  orderCalculate: function() {
    let that = this;
    let param_data = that.getValue();

    app.sendRequest({
      url: 'System.Order.orderCalculate',
      data: {
        data: JSON.stringify(param_data)
      },
      success: function(res) {
        let code = res.code;
        let data = res.data;
        console.log(res);
        if (code == 0) {
          if (data.offset_money_array == undefined) {
            data.offset_money_array = {};
            data.offset_money_array.point = {};
            data.offset_money_array.point.num = 0;
            data.offset_money_array.point.offset_money = 0;
          }
          let param = {
            tax_money: parseFloat(data.tax_money).toFixed(2),
            total_money: parseFloat(data.total_money).toFixed(2),
            shipping_money: parseFloat(data.shipping_money).toFixed(2),
            promotion_money: parseFloat(data.promotion_money).toFixed(2),
            goods_money: parseFloat(data.goods_money).toFixed(2),
            pay_money: parseFloat(data.pay_money).toFixed(2),
            use_point: data.offset_money_array.point.num,
            use_point_money: parseFloat(res.data.offset_money_array.point.offset_money).toFixed(2),
          };

          if (data.order_type == 6) {
            param.pay_money = parseFloat(res.data.presell_order_pay_money).toFixed(2);
          }
          that.setData(param);
        } else {
          showBox(that, res.message);
        }
      }
    });
  },

  /**
   * 订单验证
   */
  verify: function(data = null) {
    let that = this;
    // 非虚拟商品
    if (data.is_virtual == 0) {
      if (data.address_id == 0) {
        app.showBox(that, '请先选择收货地址');
        return false;
      }
      // 如果用户选择商家配送的话 不考虑配送方式有没有开启
      if (data.pay_type != 4) {
        if (data.shipping_info.shipping_type == undefined || data.shipping_info.shipping_type == 0) {
          app.showBox(that, '商家未启用配送方式');
          return false;
        }
      }
      if (data.shipping_info.shipping_type == 2 && data.shipping_info.pick_up_id == 0) {
        app.showBox(that, '请先选择自提点');
        return false;
      }
    } else {
      if (!app.getRegex(data.user_telephone, 'mobile')) {
        app.showBox(that, '请输入正确的手机号');
        return false;
      }
    }
    // 发票
    let is_need_invoice = that.data.is_need_invoice;
    if (is_need_invoice == 1) {
      let invoice_title = that.data.invoice_title;
      if (!app.getRegex(invoice_title, 'invoice')) {
        app.showBox(that, '请填写发票抬头');
        return false;
      }
      let taxpayer_identification_number = that.data.taxpayer_identification_number;
      if (!app.getRegex(taxpayer_identification_number, 'invoice')) {
        app.showBox(that, '请输入纳税人识别号');
        return false;
      }
    }
    return true;
  },

  /**
   * 输入手机号码
   */
  inputTel: function(e) {
    let that = this;
    let user_telephone = e.detail.value;
    that.setData({
      user_telephone: user_telephone
    })
  },

  /**
   * 支付方式
   */
  payType: function(event) {
    let that = this;
    let status = event.currentTarget.dataset.status;

    that.setData({
      pay_type_option: status,
      mask_status: status
    })
  },

  /**
   * 选择支付方式
   */
  selectPayType: function(e) {
    let that = this;
    let pay_type_id = e.currentTarget.dataset.flag;

    that.setData({
      pay_type_id: pay_type_id,
    })

    that.orderCalculate();
    that.closePoupo();
  },

  /**
   * 配送方式
   */
  deliveryType: function(event) {
    let that = this;
    let status = event.currentTarget.dataset.status;

    that.setData({
      delivery_option: status,
    })
  },

  /**
   * 选择配送方式
   */
  expressTypeSelect: function(e) {
    let that = this;
    let express_type_id = e.currentTarget.dataset.type;

    that.setData({
      express_type_id: express_type_id,
    })

    that.orderCalculate();
  },

  /**
   * 选择物流公司
   */
  selectExpressCompany: function(e) {
    let that = this;
    let data = e.currentTarget.dataset;
    let express_company_id = data.id;
    let express_company_name = data.name;

    that.setData({
      express_company_id: express_company_id,
      express_company_name: express_company_name,
    })

    that.orderCalculate();
  },

  /**
   * 优惠券
   */
  couponStatus: function(e) {
    let that = this;

    that.setData({
      coupon_option: 1,
    })
  },

  /**
   * 选择优惠券
   */
  selectCoupon: function(e) {
    let that = this;
    let id = e.currentTarget.dataset.id;
    let money = e.currentTarget.dataset.money;
    let coupon_id = that.data.coupon_id;
    id = id == coupon_id ? 0 : id;
    money = id == coupon_id ? 0 : money;

    that.setData({
      coupon_id: id,
      coupon_money: money
    })

    that.orderCalculate();
  },

  /**
   * 选择自提地址
   */
  pickUpSelect: function(e) {
    let that = this;
    let data = e.currentTarget.dataset;
    let pick_up_id = data.id;
    let pick_up_name = data.name;

    that.setData({
      pick_up_id: pick_up_id,
      pick_up_name: pick_up_name
    })

    that.orderCalculate();
  },

  /**
   * 发票
   */
  invoiceType: function(e) {
    let that = this;

    that.setData({
      invoice_option: 1,
    })
  },

  /**
   * 选择是否需要发票
   */
  selectInvoice: function(e) {
    let is_need_invoice = e.detail.value === true ? 1 : 0;

    this.setData({
      is_need_invoice: is_need_invoice,
    })
    this.orderCalculate();
  },

  /**
   * 选择发票内容
   */
  selectInvoiceContent: function(e) {
    let that = this;
    let content = e.currentTarget.dataset.content;

    that.setData({
      invoice_content: content
    })
  },

  /**
   * 修改配送时间
   */
  updateShippingTime: function(e) {
    let that = this;

    that.setData({
      shipping_time_option: 1,
      mask_status: 1
    })
  },

  /**
   * 选择配送时间
   */
  selectShippingTime: function(e) {
    let that = this;
    let shipping_time = e.currentTarget.dataset.time;
    let shipping_time_info = e.currentTarget.dataset.date;

    that.setData({
      shipping_time: shipping_time,
      shipping_time_info: shipping_time_info
    })
  },

  /**
   * 选择配送时间段
   */
  selectShippingTimeOut: function(e) {
    let that = this;
    let distribution_time_out = e.currentTarget.dataset.time;

    that.setData({
      distribution_time_out: distribution_time_out,
    })
  },

  /**
   * 删除配送时间
   */
  deleteShippingTime: function(e) {
    let that = this;

    that.setData({
      distribution_time_out: '',
      shipping_time: 0,
    })
  },

  /**
   * 关闭弹框
   */
  closePoupo: function(e) {
    let that = this;
    let invoice_option = that.data.invoice_option;
    if (invoice_option == 1) {
      //发票检测
      let invoice_title = that.data.invoice_title;
      if (app.checkEmpty(invoice_title, '') == '') {
        app.showBox(that, '请填写发票抬头');
        return false;
      }

      let taxpayer_identification_number = that.data.taxpayer_identification_number;
      if (app.checkEmpty(invoice_title, '') == '') {
        app.showBox(that, '请填写纳税人识别号');
        return false;
      }
    }
    let param = {
      mask_status: 0, //遮罩层
      pay_type_option: 0, //支付方式弹框
      shipping_time_option: 0, //配送时间弹框
    };
    let mask_status = that.data.mask_status;
    if (mask_status == 0) {
      param.delivery_option = 0;
      param.invoice_option = 0; //发票弹框
      param.coupon_option = 0;
    }
    that.setData(param);
  },

  /**
   * 选择预售款项
   */
  presellOptions: function(e) {
    let that = this;
    let presell_options = that.data.presell_options;
    let is_full_payment = that.data.is_full_payment;
    let type = e.currentTarget.dataset.type;
    if (is_full_payment === type) {
      return true;
    }
    that.setData({
      is_full_payment: type,
    })
    that.orderCalculate();
  },

  /**
   * 积分输入
   */
  inputPoint: function(event) {
    let that = this;
    let use_point = parseInt(event.detail.value);
    let max_use_point = parseInt(that.data.max_use_point);

    if (use_point < 0) {
      use_point = 0;
      app.showBox(that, '积分输入错误');
    }

    if (use_point > max_use_point) {
      use_point = max_use_point;
    }

    that.setData({
      use_point: use_point,
    })
    return use_point;
  },

  /**
   * 发票抬头输入
   */
  inputInvoiceTitle: function(e) {
    let that = this;
    let title = e.detail.value;

    that.setData({
      invoice_title: title
    })
  },

  /**
   * 纳税人识别号输入
   */
  inputTaxpayerIdentificationNumber: function(e) {
    let that = this;
    let identification_number = e.detail.value;

    that.setData({
      taxpayer_identification_number: identification_number
    })
  },

  /**
   * 留言输入
   */
  inputMessage: function(e) {
    let that = this;
    let buyer_invoice = e.detail.value;

    that.setData({
      buyer_invoice: buyer_invoice
    })
  },

  /**
   * 提交订单
   */
  commitOrder: function(event) {
    let that = this;

    let param_data = that.getValue();
    if (that.verify(param_data)) {

      let order_tag = that.data.order_tag;
      app.sendRequest({
        url: 'System.Order.orderCreate',
        data: {
          data: JSON.stringify(param_data)
        },
        success: function(res) {
          let code = res.code;
          let data = res.data;

          if (code == 0) {
            if (order_tag == 2) {
              that.deleteCart();
            }
            let out_trade_no = data.out_trade_no;
            let pay_money = that.data.pay_money;
            if (param_data.pay_type == 4 || parseFloat(pay_money) == 0) {
              wx.reLaunch({
                url: '/pagesother/pages/pay/paycallback/paycallback?status=1&out_trade_no=' + out_trade_no,
              })
            } else {
              wx.navigateTo({
                url: '/pagesother/pages/pay/getpayvalue/getpayvalue?out_trade_no=' + out_trade_no
              })
            }
          }
          console.log(res)
        }
      })
    }
  },

  /**
   * 清除购物车
   */
  deleteCart: function() {
    let goods_sku_list = this.data.goods_sku_list;
    app.sendRequest({
      url: 'System.Goods.deleteCartByGoods',
      data: {
        goods_sku_list: goods_sku_list
      },
      success: function(res) {}
    });
  }
})